package com.bosssoft.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bosssoft.entity.dto.FibTrainBudgetDTO;
import com.bosssoft.entity.po.FibConferenceBudgetPO;
import com.bosssoft.entity.po.FibTrainBudgetPO;
import com.bosssoft.entity.vo.FibConferenceBudgetVO;
import com.bosssoft.entity.vo.FibTrainBudgetVO;
import com.bosssoft.exception.DaoException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bosssoft.mapper.FibTrainBudgetMapper;
import com.bosssoft.service.FibTrainBudgetService;

import javax.annotation.Resource;

/**
 * @author Li kexi
 * Created on 2021/8/19.15:46
 */
@Service
@Slf4j
public class FibTrainBudgetServiceImpl extends ServiceImpl<FibTrainBudgetMapper, FibTrainBudgetPO> implements FibTrainBudgetService{

    @Resource
    private FibTrainBudgetMapper fibTrainBudgetMapper;

    @Override
    public int updateBatch(List<FibTrainBudgetPO> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<FibTrainBudgetPO> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<FibTrainBudgetPO> list) {
        return baseMapper.batchInsert(list);
    }
    @Override
    public int insertOrUpdate(FibTrainBudgetPO record) {
        return baseMapper.insertOrUpdate(record);
    }
    @Override
    public int insertOrUpdateSelective(FibTrainBudgetPO record) {
        return baseMapper.insertOrUpdateSelective(record);
    }
    @Autowired
    private FibTrainBudgetService fibTrainBudgetService;

    @Override
    public boolean addTrain(FibTrainBudgetDTO fibTrainBudgetDTO) {
        FibTrainBudgetPO fibTrainBudgetPO = new FibTrainBudgetPO();
        BeanUtils.copyProperties(fibTrainBudgetDTO, fibTrainBudgetPO);

        //todo:创建人（更新人）信息获取
        boolean save = fibTrainBudgetService.save(fibTrainBudgetPO);
        return save;
    }

    @Override
    public boolean editTrain(FibTrainBudgetDTO fibTrainBudgetDTO) {

        FibTrainBudgetPO fibTrainBudgetPO = new FibTrainBudgetPO();
        BeanUtils.copyProperties(fibTrainBudgetDTO, fibTrainBudgetPO);
        FibTrainBudgetPO byId = getById(fibTrainBudgetPO.getId());
        //todo:修改人的获取方式待定
        boolean b = updateById(fibTrainBudgetPO);
        return b;
    }

    @Override
    public Page<FibTrainBudgetVO> selectTrain(Integer current, Integer size) {
        Page<FibTrainBudgetPO> page = new Page<>(current, size);
        Page<FibTrainBudgetPO> poPage = fibTrainBudgetMapper.selectPage(page, null);
        Page<FibTrainBudgetVO> voPage = new Page<>(current, size);
        BeanUtils.copyProperties(poPage,voPage);
        return voPage;
    }
}
